package com.wb.core12线程;

import javax.naming.Name;

/**
 * @author 黄衡熙
 * @version 1.0
 */
/*
* 使用线程实现售票功能,共有两个售票窗口,共出售100张票
* */
public class Test03_售票练习 {
   public static void main(String[] args) {
       Ticket ticket = new Ticket();
       Thread t1 = new Thread(ticket, "窗口1");
       Thread t2 = new Thread(ticket, "窗口2");
       t1.start();
       t2.start();
   }
}
class Ticket implements Runnable {
    private int num = 100;
    @Override
    public void run() {
        while (num > 0) {
            System.out.println(Thread.currentThread().getName() + "正在出票,票号为:" + num--);
        }
    }
}